import pymysql
import time, os

try:
    conn = pymysql.connect(host="172.16.0.12", port=3306, user="root", passwd="1Qazxsw2!", db="parkinglot")  # 腾讯数据库
    print('已连接数据库parkinglot')
except:
    conn = pymysql.connect(host="172.16.0.12", port=3306, user="root", passwd="1Qazxsw2!", charset='utf8')  #腾讯数据库
    cur = conn.cursor()
    comm = 'create database parkinglot'
    cur.execute(comm)
    cur.close()
    print('新建数据库parkinglot')
conn.close()
time.sleep(1)
#试着连接表格，如果没有则建表
os.system('python3 /home/Parking_lot/manage.py migrate')
time.sleep(1)
os.system()




